import express from 'express'
import userRouter from '../user/user.router'
import authRouter from '../auth/auth.router'
import likeRouter from '../like/like.router'
import postRouter from '../post/post.router'
import {defaultErrorHandler} from './app.middleware'
import bodyParser from 'body-parser'
import { currentUser} from '../auth/auth.middleware'

const app=express()

// 用户身份
app.use(currentUser)

app.use(bodyParser.json())
app.use(bodyParser.urlencoded({extended:true}))

app.use(
    userRouter,
    authRouter,
    likeRouter,
    postRouter
)

app.use(defaultErrorHandler)

export default app